<?php
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.inc.php';
$link=connect();
if(isset($_POST['submit'])){
	
	if(is_uploaded_file($_FILES['myfile']['tmp_name'])){
		$arr=pathinfo($_FILES['myfile']['name']);
		$newName=date('YmdGis');
		$url="uploads/{$newName}.{$arr['extension']}";
		if(move_uploaded_file($_FILES['myfile']['tmp_name'],"uploads/{$newName}.{$arr['extension']}")){

			$query="update userinfo set headImg='{$url}' where username='".$_COOKIE['youyou']['name']."'";
			$result=execute($link,$query);
			$row=mysqli_affected_rows($link);
			if($row){
				skip('information.php', 'ok', '恭喜您！上传成功！');
			}else{
				skip('information.php', 'error', '对不起！上传失败,请稍后重试！');
			}
		}else{
			skip('information.php', 'error', '对不起！上传失败,请稍后重试！');
		}
	}else{
		skip('information.php', 'error', '对不起！请选择合法的文件！');
	}
}
?>